package org.example.easybuy.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

@Service
public class EmailService {

    @Autowired
    private JavaMailSender javaMailSender;

    public boolean sendMail(String accept,String subject,String content)
    {
        SimpleMailMessage simpleMailMessage=new SimpleMailMessage();
        simpleMailMessage.setFrom("3507623335@qq.com");
        simpleMailMessage.setTo(accept);
        simpleMailMessage.setSubject(subject);
        simpleMailMessage.setText(content);
        try{
            javaMailSender.send(simpleMailMessage);
            return true;
        }catch(Exception e)
        {
            return false;
        }
    }
}
